package control;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import android.os.Environment;
import android.util.Xml;

public class XmlManager {

	public static void saveModel(String name, int xWindow, int yWindow) throws IOException {

		File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/automatas");
		sampleDir.mkdirs();

		File file;
		file = File.createTempFile(name, ".txt", sampleDir);
		FileOutputStream writer = new FileOutputStream(file);

		org.xmlpull.v1.XmlSerializer serializer = Xml.newSerializer();
		serializer.setOutput(writer, "UTF-8");
		serializer.startDocument(null, true);
		serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);

		serializer.startTag(null, "root");

		serializer.startTag("", "window");
		serializer.attribute("", "x", ""+xWindow);
		serializer.attribute("", "y", ""+yWindow);
		serializer.endTag("", "window");

		serializer.startTag("", "nodes");

		serializer.endTag("", "nodes");

		serializer.endDocument();

	}

}
